-- ==== BEGIN LICENSE BLOCK ====
-- storyboard-addon - Copyright (C) Arnaud Charnoz, 2006-2010.
-- Distributed under the terms of the GNU Lesser General Public License (LGPL) as
-- published by the Free Software Foundation.
-- ===== END LICENSE BLOCK ====
 
StorylineDB = {};
 
StorylineDB.__index = StorylineDB;
 
-------------------------------------------------------------------------------
 
function StorylineDB:new()
    
    local self = {};
    setmetatable(self, StorylineDB);
     
    self.db = {};
  
    return self;
end

-------------------------------------------------------------------------------
 
function StorylineDB:addStoryline( storyline )

    self.db[ storyline:getId() ] = storyline:exportToString() ;

end

-------------------------------------------------------------------------------

function StorylineDB:getStoryline( key )
    
    storyline = Storyline:new();
    storyline:importFromString( self.db[ key ] );
    return storyline;
    
end

-------------------------------------------------------------------------------

function StorylineDB:getStringStoryline( key )

    return self.db[ key ];
   
end

-------------------------------------------------------------------------------

function StorylineDB:removeStoryline( key )
    
    self.db[ key ] = nil;
    
end

-------------------------------------------------------------------------------

--[ Method to test if a key is present in db ]-- 
function StorylineDB:hasKey( key )
    
    for k,v in pairs(self.db) do
        if ( k == key )
        then
            return true;
        end
    end
  
    return false;
end

-------------------------------------------------------------------------------